import NProgress from "nprogress";
import "nprogress/nprogress.css";
import { createRouter, createWebHistory } from "vue-router";
const routes = [
  {
    path: "/",
    redirect: "/login"
  },
  {
    path: "/login",
    name: "login",
    component: () => import("../views/login/loginPage.vue")
  },
  {
    path: "/index",
    name: "index",
    component: () => import("../layout/index.vue"),
    children: [
      {
        path: "makeNegativeByTube",
        component: () => import("../views/script-generator/makeNegativeByTube.vue")
      },
      {
        path: "makeAbnormalById",
        component: () => import("../views/script-generator/makeAbnormalById.vue")
      },
      {
        path: "makeAbnormalByTubeCode",
        component: () => import("../views/script-generator/makeAbnormalByTubecode.vue")
      },
      {
        path: "code_1",
        component: () => import("../views/script-generator/code_1.vue")
      },
      {
        path: "yinToYang",
        component: () => import("../views/script-generator/yinToYang.vue")
      },
      {
        path: "yangToYin",
        component: () => import("../views/script-generator/yangToYin.vue")
      },
      {
        path: "removeRepeatId",
        component: () => import("../views/script-generator/removeRepeatId.vue")
      },
      {
        path: "over12HoursNoCheck2Abnormal",
        component: () => import("../views/script-generator/over12HoursNoCheck2Abnormal.vue")
      },
      {
        path: "foreignerInforByTime",
        component: () => import("../views/script-generator/foreignerInforByTime.vue")
      },
      {
        path: "departure",
        component: () => import("../views/script-generator/departure.vue")
      },
      {
        path: "sampleType",
        component: () => import("../views/script-generator/sampleType.vue")
      },
      {
        path: "jobPush",
        component: () => import("../views/script-generator/jobPush.vue")
      },
      {
        path: "addEntry",
        component: () => import("../views/script-generator/addEntry.vue")
      },
      {
        path: "makeNegativeByTubeAndNotBindTube",
        component: () => import("../views/script-generator/makeNegativeByTubeAndNotBindTube.vue")
      },
      {
        path: "bigBatchAddInfo",
        component: () => import("../views/script-generator/bigBatchAddInfo.vue")
      }
    ]
  },
  {
    path: "/:catchAll(.*)",
    name: "404",
    component: () => import("../views/404/errorPage.vue")
  }
];

const router = createRouter({
  // at https://example.com/folder
  // createWebHashHistory() // 给出的网址为 `https://example.com/folder#`
  // createWebHashHistory('/folder/') // 给出的网址为 `https://example.com/folder/#`
  // 如果在 base 中提供了 `#`，则它不会被 `createWebHashHistory` 添加
  // createWebHashHistory('/folder/#/app/') // 给出的网址为 `https://example.com/folder/#/app/`
  // 你应该避免这样做，因为它会更改原始 url 并打断正在复制的 url
  // createWebHashHistory('/other-folder/') // 给出的网址为 `https://example.com/other-folder/#`
  //
  // at file:///usr/etc/folder/index.html
  // 对于没有 `host` 的位置，base被忽略
  // createWebHashHistory('/iAmIgnored') // 给出的网址为 `file:///usr/etc/folder/index.html#`
  history: createWebHistory(process.env.VUE_APP_ROUTER),
  routes
});

router.beforeEach((to, from, next) => {
  NProgress.start();
  next();
});

router.afterEach(() => {
  NProgress.done();
});

export default router;
